svg = 
VAR UnitText = "Satış"
VAR ActualValue = [toplam_adet]
VAR GoalValue = [toplam_hedef]

VAR Pct = DIVIDE ( ActualValue, GoalValue )
VAR PctSafe = COALESCE ( Pct, 0 )
VAR PctClamped = MIN ( MAX ( PctSafe, 0 ), 1 )

VAR DiffValue = ActualValue - GoalValue
VAR DiffPct = DIVIDE ( DiffValue, GoalValue )

VAR StatusText =
    SWITCH (
        TRUE (),
        ISBLANK ( Pct ), "Veri Yok",
        Pct < 0.8, "Kritik",
        Pct < 1, "Hedefe Yakın",
        "Hedef Tamam"
    )

VAR StatusColor =
    SWITCH (
        TRUE (),
        ISBLANK ( Pct ), "rgb(100,116,139)",
        Pct < 0.8, "rgb(239,68,68)",
        Pct < 1, "rgb(245,158,11)",
        "rgb(16,185,129)"
    )

VAR StatusBg =
    SWITCH (
        TRUE (),
        ISBLANK ( Pct ), "rgb(241,245,249)",
        Pct < 0.8, "rgb(254,242,242)",
        Pct < 1, "rgb(255,251,235)",
        "rgb(236,253,245)"
    )

VAR ActualText =
    IF (
        ISBLANK ( ActualValue ),
        "-",
        FORMAT ( ActualValue, "#,0" )
    )

VAR GoalText =
    IF (
        ISBLANK ( GoalValue ),
        "-",
        FORMAT ( GoalValue, "#,0" )
    )

VAR PctText =
    IF (
        ISBLANK ( Pct ),
        "-",
        FORMAT ( Pct, "0.0%" )
    )

VAR DiffText =
    IF (
        ISBLANK ( GoalValue ),
        "-",
        IF ( DiffValue >= 0, "+", "" ) &
        FORMAT ( DiffValue, "#,0" )
    )

VAR DiffPctText =
    IF (
        ISBLANK ( DiffPct ),
        "",
        IF ( DiffPct >= 0, "+", "" ) &
        FORMAT ( DiffPct, "0.0%" )
    )

VAR DiffColor =
    IF (
        ISBLANK ( DiffValue ),
        "rgb(100,116,139)",
        IF (
            DiffValue >= 0,
            "rgb(16,185,129)",
            "rgb(239,68,68)"
        )
    )

VAR BarX = 24
VAR BarY = 170
VAR BarW = 312
VAR BarH = 14

VAR FillW =
    ROUND ( PctClamped * BarW, 0 )

VAR FillWSafe =
    IF (
        FillW > 0,
        MAX ( FillW, 7 ),
        0
    )

RETURN

"data:image/svg+xml;utf8," &

"<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 360 240'>" &

"<rect x='5' y='5' width='350' height='230' rx='16'
fill='rgb(255,255,255)'
stroke='rgb(226,232,240)'
stroke-width='1'/>" &


"<rect x='14' y='22' width='5' height='194' rx='2.5'
fill='" & StatusColor & "'/>" &


"<text x='32' y='37'
font-family='Segoe UI'
font-size='12'
font-weight='600'
fill='rgb(71,85,105)'>" &
UnitText &
"</text>" &


"<rect x='224' y='18' width='112' height='28' rx='14'
fill='" & StatusBg & "'/>" &

"<circle cx='241' cy='32' r='5'
fill='" & StatusColor & "'/>" &

"<text x='253' y='36'
font-family='Segoe UI'
font-size='10'
font-weight='600'
fill='" & StatusColor & "'>" &
StatusText &
"</text>" &


"<text x='32' y='91'
font-family='Segoe UI'
font-size='42'
font-weight='700'
fill='rgb(15,23,42)'>" &
PctText &
"</text>" &

"<text x='33' y='108'
font-family='Segoe UI'
font-size='9'
font-weight='600'
fill='rgb(148,163,184)'>
HEDEF GERÇEKLEŞME
</text>" &


"<text x='332' y='78'
text-anchor='end'
font-family='Segoe UI'
font-size='16'
font-weight='700'
fill='" & DiffColor & "'>" &
DiffText &
"</text>" &

"<text x='332' y='96'
text-anchor='end'
font-family='Segoe UI'
font-size='10'
font-weight='600'
fill='" & DiffColor & "'>" &
DiffPctText &
"</text>" &

"<text x='332' y='110'
text-anchor='end'
font-family='Segoe UI'
font-size='8'
font-weight='600'
fill='rgb(148,163,184)'>
HEDEF FARKI
</text>" &


"<rect x='32' y='125'
width='140'
height='32'
rx='7'
fill='rgb(248,250,252)'
stroke='rgb(226,232,240)'
stroke-width='1'/>" &

"<text x='42' y='139'
font-family='Segoe UI'
font-size='8'
font-weight='600'
fill='rgb(148,163,184)'>
GERÇEKLEŞEN
</text>" &

"<text x='42' y='153'
font-family='Segoe UI'
font-size='12'
font-weight='700'
fill='rgb(51,65,85)'>" &
ActualText &
"</text>" &


"<rect x='182' y='125'
width='150'
height='32'
rx='7'
fill='rgb(248,250,252)'
stroke='rgb(226,232,240)'
stroke-width='1'/>" &

"<text x='192' y='139'
font-family='Segoe UI'
font-size='8'
font-weight='600'
fill='rgb(148,163,184)'>
HEDEF
</text>" &

"<text x='192' y='153'
font-family='Segoe UI'
font-size='12'
font-weight='700'
fill='rgb(51,65,85)'>" &
GoalText &
"</text>" &


"<rect x='" & BarX & "'
y='" & BarY & "'
width='" & BarW & "'
height='" & BarH & "'
rx='7'
fill='rgb(226,232,240)'/>" &

IF (
    FillWSafe > 0,
    "<rect x='" & BarX & "'
    y='" & BarY & "'
    width='" & FillWSafe & "'
    height='" & BarH & "'
    rx='7'
    fill='" & StatusColor & "'/>",
    ""
) &


"<line x1='336'
y1='166'
x2='336'
y2='190'
stroke='rgb(71,85,105)'
stroke-width='2'/>" &

"<circle cx='336'
cy='177'
r='3'
fill='rgb(71,85,105)'/>" &


"<text x='24' y='202'
font-family='Segoe UI'
font-size='8'
fill='rgb(148,163,184)'>
0%
</text>" &

"<text x='180' y='202'
text-anchor='middle'
font-family='Segoe UI'
font-size='8'
fill='rgb(148,163,184)'>
50%
</text>" &

"<text x='336' y='202'
text-anchor='end'
font-family='Segoe UI'
font-size='8'
font-weight='600'
fill='rgb(100,116,139)'>
100%
</text>" &


"<line x1='24'
y1='213'
x2='336'
y2='213'
stroke='rgb(226,232,240)'
stroke-width='1'/>" &


"<text x='24' y='228'
font-family='Segoe UI'
font-size='9'
fill='rgb(100,116,139)'>
Performans Durumu
</text>" &

"<text x='336' y='228'
text-anchor='end'
font-family='Segoe UI'
font-size='9'
font-weight='700'
fill='" & StatusColor & "'>" &
StatusText &
"</text>" &

"</svg>"